from pathlib import Path

'''
cwd: current working directory
'''

current_dir = Path.cwd()  # 当前目录
# 与该文件 同级的 目录
static_folder = Path('static')
template_folder = Path('template')
apps_folder = Path('apps')
print(static_folder.absolute())  # 绝对路径
print(template_folder.absolute())
print(apps_folder.absolute())
# is_dir() 和 is_file() exists()
print(static_folder.is_dir())
print(static_folder.is_file())
print(static_folder.exists())
# attr: stem suffix 和 parent
current_file = current_dir / "how_to_use_pathlib.py"
print(current_file.stem)  # file name
print(current_file.suffix)  # file suffix
print(current_file.parent)  # 该文件的父级目录

# (current_dir / 'test.py').touch() # 在当前目录创建文件
(current_dir / 'test.py').unlink()  # 在当前目录删除文件

BASE_DIR = Path(__file__).resolve().parent.parent
print(BASE_DIR)